package com.medical.controller;

import com.medical.domain.R;
import com.medical.model.entity.DeptScore;
import com.medical.service.DeptScoreService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @author TISNIW
 * @version 1.0
 * @desc
 */
@RestController
@RequestMapping("/dept/score")
public class DeptScoreController {

    @Resource
    private DeptScoreService deptScoreService;

    // 获取所有评分
    @GetMapping
    public R<List<DeptScore>> getAllScores() {
        return R.ok(deptScoreService.list());
    }
    //为指定部门评分
    @PostMapping("/{deptId}")
    public R<DeptScore> saveScore(@PathVariable Long deptId, @RequestBody DeptScore deptScore) {
        return R.ok(deptScoreService.saveScore(deptId, deptScore));
    }
    // 获取部门评分
    @GetMapping("/dept/{deptId}")
    public R<DeptScore> getDeptScore(@PathVariable Long deptId) {
        return R.ok(deptScoreService.getByDeptId(deptId));
    }
    // 新增或更新评分
    @PostMapping
    public R<Boolean> saveScore(@RequestBody DeptScore deptScore) {
        return R.ok(deptScoreService.saveOrUpdate(deptScore));
    }
}